{% extends "admin/base_site.html" %}
{% load i18n admin_urls static admin_list simpletags %}

{#自定义的导入导出按钮权限#}
{#                            has_import_perm: {{ has_import_perm }}#}
{#                            has_export_perm: {{ has_export_perm }}#}

{% block extrastyle %}
    {{ block.super }}
    <link rel="stylesheet" type="text/css" href="{% static 'admin/css/changelists.css' %}?_=20180905"/>

    {% if cl.formset %}
        <link rel="stylesheet" type="text/css" href="{% static 'admin/css/forms.css' %}"/>
    {% endif %}
    {% if cl.formset or action_form %}
        <script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
    {% endif %}
    {{ media.css }}
    {% if not actions_on_top and not actions_on_bottom %}
        <style>
            #changelist table thead th:first-child {
                width: inherit
            }
        </style>
    {% endif %}
{% endblock %}

{% block extrahead %}
    {{ block.super }}
    {{ media.js }}
{% endblock %}

{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} change-list{% endblock %}

{% if not is_popup %}
    {% block breadcrumbs %}
        <div class="breadcrumbs">
            <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
            &rsaquo; <a
                href="{% url 'admin:app_list' app_label=cl.opts.app_label %}">{{ cl.opts.app_config.verbose_name }}</a>
            &rsaquo; {{ cl.opts.verbose_name_plural|capfirst }}
        </div>
    {% endblock %}
{% endif %}

{% block coltype %}flex{% endblock %}
{% block content_title %}

{% endblock %}
{% block content %}
    <style>
        #content {
            position: relative;
        }

        .object-tools {
            position: absolute;
            top: 16px;
            right: 20px;
            height: 50px;
            z-index: 2;
        }

        .object-tools .import_link, .object-tools .export_link {
            color: white !important;
        }

    </style>
    {% block object-tools %}
        <ul class="object-tools">
            {% block object-tools-items %}
                {% if has_add_permission %}
                    {{ block.super }}
                {% endif %}
            {% endblock %}
        </ul>

        {% if custom_import_and_export_buttons %}
        <div>
            <div class="my_table_title" style="display: flex;">

                <span
                    style="
                        font-weight: 700;
                        margin: 5px 20px 20px 20px;
                        /*margin-top: 10px;*/
                        font-size: 20px!important;
                        color: #666;
                    "
                >
                    {{ opts.verbose_name_plural }}
                </span>

                <div class="my_buttons" style="margin-left: auto;margin-right: 5px;margin-top: 10px">
                    {% if has_export_perm %}
                    <a href="export_all_excel/" target="_blank">
                       <button type="button" class="el-button el-button--default el-button--small"

                                style="
                                float: right;
                                margin-right: 5px;"

                               data-name="export_all_excel"><!----><!---->
                            <span class="fas fa-download"></span>
                            <span>
                                全部导出
                            </span>
                        </button>
                    </a>
                    {% endif %}

                    {% if has_import_perm %}
                    <a href="import-csv/">
                        <button type="button" class="el-button el-button--default el-button--small"

                                style="
                                float: right;
                                margin-right: 10px;"

                                data-name="export_as_csv">

                            <i class="fas fa-upload"></i>
                            <span>
                                导入数据
                            </span>
                        </button>
                    </a>
                    {% endif %}

                </div>

            </div>
        </div>
        {% endif %}

    {% endblock %}

    <div id="content-main">
        {% if cl.formset.errors %}
            <p class="errornote">
                {% if cl.formset.total_error_count == 1 %}{% trans "Please correct the error below." %}{% else %}
                    {% trans "Please correct the errors below." %}{% endif %}
            </p>
            {{ cl.formset.non_form_errors }}
        {% endif %}
        <div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
            {% block search %}{% search_form cl %}{% endblock %}
            {% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}

            <form id="changelist-form" method="post" {% if cl.formset.is_multipart %}
                  enctype="multipart/form-data" {% endif %} novalidate>{% csrf_token %}
                <!--Compatible with django 3.2 x-->
                <button style="display:none" name="index"></button>
                {% if cl.formset %}
                    <div>{{ cl.formset.management_form }}</div>
                {% endif %}

                {% block result_list %}
                    {% simpleui_admin_actions %}
{#                    {% admin_actions %}#}
{#                    {% include 'admin/simpleui_actions.html' %}#}
                    {% result_list cl %}

                {% endblock %}
                {% block pagination %}{% pagination cl %}{% endblock %}
            </form>
        </div>
    </div>
    <script type="text/javascript">
        $(".object-tools").hide().find('li a').each(function () {
            _action.exts.push({
                name: $(this).text(),
                url: $(this).attr('href')
            })
        })
        if(parent.addEvent){
            parent.addEvent('title','{% get_verbose_name_plural %}')
        }
    </script>
{% endblock %}


